package com.wonderful.eyepetizer.app.ktx

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken

/**
 * Desc:
 * @Author: wonderful
 * @Time: 2024/2/20 19:40
 */

val gson by lazy { Gson() }

fun toJson(obj: Any): String = gson.toJson(obj)

inline fun <reified T> fromJson(json: String): T {
    val type = object : TypeToken<T>() {}.type
    return gson.fromJson(json, type)
}